package com.cloud.portmana.web;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.json.JSONArray;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
 
 import com.cloud.portmana.ModuleConstant;
import com.cloud.portmana.dto.BgCycleThreeDS;
import com.cloud.portmana.entity.EntitySaleStatistics;
import com.cloud.portmana.entity.dao.IBgStatisticsManaSaleDao;
import com.cloud.portmana.ser.IBgStatisticsManaSaleService;
import com.cloud.util.base.BaseAction;
import com.cloud.util.base.IUserInfo;
import com.cloud.util.other.StringUtil;
import com.cloud.util.page.PageInfo;
import com.google.gson.Gson;
import com.mchange.v2.c3p0.stmt.GooGooStatementCache;

//listsale.do 
@Controller
@RequestMapping("bgCycleStatisticsManaSale")
public class BgCycleStatisticsManaSaleAction extends BaseAction{
	@Resource(name="bgStatisticsManaSaleService")
	private IBgStatisticsManaSaleService bgStatisticsManaSaleService;
	@Resource(name="bgStatisticsManaSaleDao")
	private IBgStatisticsManaSaleDao bgStatisticsManaSaleDao;
	
	@RequestMapping("listsale.do")
	public String listsale(ModelMap modelMap,PageInfo pageInfo,BgCycleThreeDS cycleThreeDS,HttpServletRequest request){	
		IUserInfo userInfo=getUserInfo(request);
		System.out.println(userInfo.getUserId());
 
		List<List<EntitySaleStatistics>>  fourlist = bgStatisticsManaSaleDao.getfourSalelist(userInfo);
		Gson fd = new Gson();
		fd.toJson(fourlist.get(0));
		System.out.println("++++=="+fd.toJson(fourlist.get(0)));
		fd.toJson(fourlist.get(1));
		System.out.println("++++=="+fd.toJson(fourlist.get(1)));
		fd.toJson(fourlist.get(2));
		System.out.println("++++=="+fd.toJson(fourlist.get(2)));
		fd.toJson(fourlist.get(3));
		System.out.println("++++=="+fd.toJson(fourlist.get(3)));
		
		modelMap.put("daylist", fd.toJson(fourlist.get(0)));
		modelMap.put("monthlist", fd.toJson(fourlist.get(1)));
		modelMap.put("quarterlist", fd.toJson(fourlist.get(2)));
		modelMap.put("yearlist", fd.toJson(fourlist.get(3)));
 		modelMap.put("pageInfo",pageInfo );
		modelMap.put("cycleThreeDS",cycleThreeDS );
		 
 	return getViewsModelPathSys(ModuleConstant.MODEL_PATH+"bgCycleStatisticsMana/bgCycleStatisticsManaSale/salePie");
		
	}
	@RequestMapping("citySalePie.dop")
	public String citySalePie(ModelMap modelMap,PageInfo pageInfo,BgCycleThreeDS cycleThreeDS,HttpServletRequest request,String Province,String type){	
		IUserInfo userInfo=getUserInfo(request);
		System.out.println(userInfo.getUserId());
		pageInfo = bgStatisticsManaSaleService.getPageInfoCity(pageInfo,userInfo,Province,type,cycleThreeDS);
		
 		
		modelMap.put("pageInfo",pageInfo );
		modelMap.put("cycleThreeDS",cycleThreeDS ); 
 	return getViewsModelPathSys(ModuleConstant.MODEL_PATH+"bgCycleStatisticsMana/bgCycleStatisticsManaSale/saleList");
		
	}
	
}
